-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8353749: Improve security warning when using JKS or JCEKS keystores #27624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
👋 Welcome back hchao! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
@haimaychao The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
| jar.contains.internal.inconsistencies.result.in.different.contents.via.jarfile.and.jarinputstream=This JAR file contains internal inconsistencies that may result in different contents when reading via JarFile and JarInputStream: | ||
| signature.verification.failed.on.entry.1.when.reading.via.jarinputstream=Signature verification failed on entry %s when reading via JarInputStream | ||
| signature.verification.failed.on.entry.1.when.reading.via.jarfile=Signature verification failed on entry %s when reading via JarFile | ||
| outdated.storetype.warning=%1$s uses outdated cryptographic algorithms and will be removed in a future release. Migrate to PKCS12 using:\n\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call this "jks.storetype.warning" so it is consistent with keytool.properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| private boolean signerSelfSigned = false; | ||
| private boolean allAliasesFound = true; | ||
| private boolean hasMultipleManifests = false; | ||
| private boolean outdatedFormat = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest calling this variable "weakKeyStore".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| File storeFile = new File(keyStoreName); | ||
| if (storeFile.isFile()) { | ||
| KeyStore keyStore = KeyStore.getInstance(storeFile, storepass); | ||
| realStoreType = keyStore.getType(); | ||
| if (realStoreType.equalsIgnoreCase("JKS") | ||
| || realStoreType.equalsIgnoreCase("JCEKS")) { | ||
| outdatedFormat = true; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need the realStoreType field. If you move this check to the end of the else block starting on line 2424 (which means the keystore is a file), and just check the KeyStore.type() I think it should be sufficient, ex:
if (store.getType().equalsIgnoreCase("JKS")
|| store.getType().equalsIgnoreCase("JCEKS")) {
weakKeyStore = true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| if (outdatedFormat) { | ||
| warnings.add(String.format(rb.getString( | ||
| "outdated.storetype.warning"), | ||
| realStoreType, keystore)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass store.getType() instead of realStoreType here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| return (provider == null) ? "(no provider)" : provider.getName(); | ||
| } | ||
|
|
||
| private static void outdatedKeyStoreLog(String type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be simpler to include this warning in the constructor of sun.security.provider.JavaKeyStore. Then you don't need to call this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the warning to engineLoad() in JceKeyStore and JavaKeyStore, instead of in their constructors. Otherwise, we may get false positive warnings from KeyStore.getInstance() when it goes thru the list of providers to probe for the right keystore.
| /* | ||
| * @test | ||
| * @bug 8217375 8260286 8267319 | ||
| * @bug 8217375 8260286 8267319 8353749 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not specifically testing this issue, so I don't think you should include the bugid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should create a new test which is a subclass of this Test which checks that JKS and JCEKS produce the proper warnings when using jarsigner.
| is.close(); | ||
| } | ||
| } | ||
| if (store.getType().equalsIgnoreCase("JKS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should put in the same logic here as in keytool to check if the real storetype is JKS or JCEKS. See
| // Probe for real type. A JKS can be loaded as PKCS12 because |
|
Do we need to add a warning at |
This PR improves security warning when using JKS or JCEKS keystores.
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27624/head:pull/27624$ git checkout pull/27624Update a local copy of the PR:
$ git checkout pull/27624$ git pull https://git.openjdk.org/jdk.git pull/27624/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27624View PR using the GUI difftool:
$ git pr show -t 27624Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27624.diff
Using Webrev
Link to Webrev Comment